/* Send virtual interrupt when buffer level reaches this point */
static int t_buf_highwater;
+/* Number of records lost due to per-CPU trace buffer being full. */
+static DEFINE_PER_CPU(unsigned long, lost_records);
/* a flag recording whether initialization has been done */
/* or more properly, if the tbuf subsystem is enabled right now */
struct t_buf *buf;
struct t_rec *rec;
unsigned long flags;
-
+
BUG_ON(!tb_init_done);
if ( (tb_event_mask & event) == 0 )
local_irq_save(flags);
- if ( (buf->prod - buf->cons) >= nr_recs )
+ /* Check if space for two records (we write two if there are lost recs). */
+ if ( (buf->prod - buf->cons) >= (nr_recs - 1) )
{
+ this_cpu(lost_records)++;
local_irq_restore(flags);
return;
}
+ if ( unlikely(this_cpu(lost_records) != 0) )
+ {
+ rec = &t_recs[smp_processor_id()][buf->prod % nr_recs];
+ memset(rec, 0, sizeof(*rec));
+ rec->cycles = (u64)get_cycles();
+ rec->event = TRC_LOST_RECORDS;
+ rec->data[0] = this_cpu(lost_records);
+ this_cpu(lost_records) = 0;
+
+ wmb();
+ buf->prod++;
+ }
+
rec = &t_recs[smp_processor_id()][buf->prod % nr_recs];
rec->cycles = (u64)get_cycles();
rec->event = event;
#define TRC_VMXIO 0x00088000 /* VMX io emulation trace */
/* Trace events per class */
+#define TRC_LOST_RECORDS (TRC_GEN + 1)
#define TRC_SCHED_DOM_ADD (TRC_SCHED + 1)
#define TRC_SCHED_DOM_REM (TRC_SCHED + 2)